package com.yayo.mangement.utils;

import java.util.List;
import java.util.concurrent.*;

/**
 * @desc:
 * @author: yang
 * @date: 2022/9/6
 */
public class ThreadTask<T> {

    private static final int threads = 4;
    public static ExecutorService pool = Executors.newFixedThreadPool(threads);

    /**
     *
     * @param object 参数
     * @param callback 调用类
     * @param countDownLatch 计数器
     */
    public static void execute(Object object,Callback callback,CountDownLatch countDownLatch){
        Runnable run = () ->{
            callback.execute(object);
            countDownLatch.countDown();
        };
        pool.submit(run);
    }

    public static CountDownLatch countDownLatch(Integer count){
        return new CountDownLatch(count);
    }

    public static void main(String[] args) {

        ThreadTask.pool.shutdown();
    }

}
